﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SedCup.Code.Model;

namespace SedCup.Code.View.Components
{
    public partial class PanelWorker : UserControl
    {
        #region Types

        public enum Rank
        {
            JUNIOR, SENIOR, GURU
        }

        #endregion Types

        #region Properties

        private int doneTasks;
        /// <summary>
        /// Elvégzett feladatok száma
        /// </summary>
        public int DoneTasks
        {
            get { return doneTasks; }
            set { doneTasks = value; this.UpdatePanel(); }
        }

        private int score;
        /// <summary>
        /// A dolgozó által gyűjtött pontszám
        /// </summary>
        public int Score
        {
            get { return score; }
            set { score = value; this.UpdatePanel(); }
        }

        private string workerName;
        /// <summary>
        /// A dolgozó neve
        /// </summary>
        public string WorkerName
        {
            get { return workerName; }
            set { workerName = value; this.UpdatePanel(); }
        }

        private Rank workerRank;
        /// <summary>
        /// A dolgozó rangja
        /// </summary>
        public Rank WorkerRank
        {
            get { return workerRank; }
            set { workerRank = value; this.UpdatePanel(); }
        }

        private bool localTeam;
        /// <summary>
        /// Saját dolgozó-e
        /// </summary>
        public bool LocalTeam
        {
            get { return localTeam; }
            set { localTeam = value; this.UpdatePanel(); }
        }
        #endregion Properties

        /// <summary>
        /// 
        /// </summary>
        public PanelWorker()
        {
            InitializeComponent();

            this.BackColor = Settings.GUI_BACKCOLOR_FIELD;
        }

        /// <summary>
        /// Frissíti a panelt, hogy az új adatokat mutassa
        /// </summary>
        public virtual void UpdatePanel()
        {
            this.labelDoneJobs.Text = this.doneTasks.ToString();
            this.labelScore.Text = this.score.ToString() + " fb";
            this.labelName.Text = this.workerName;

            switch (this.workerRank)
            {
                case Rank.JUNIOR:
                    this.labelRank.Text = "Junior";
                    this.pictureBoxFace.BackgroundImage = global::SedCup.Properties.Resources.junior;
                    break;
                case Rank.SENIOR:
                    this.labelRank.Text = "Senior";
                    this.pictureBoxFace.BackgroundImage = global::SedCup.Properties.Resources.senior;
                    break;
                case Rank.GURU:
                    this.labelRank.Text = "Guru";
                    this.pictureBoxFace.BackgroundImage = global::SedCup.Properties.Resources.guru;
                    break;
            }

            this.BackColor = (this.localTeam ? Settings.GUI_BACKCOLOR_LOCALTEAM : Settings.GUI_BACKCOLOR_ENEMYTEAM);
        }
    }
}
